<?php defined('SYSPATH') or die('No direct script access.');
/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2020/06/10 9:18
 * Desc: 支付相关信息
 */
class Controller_Pc_Api_Standard_Pays extends Controller_Pc_Api_Base
{

    // 获取支付信息
    public function action_get_pay_info()
    {

        $orderid = intval($this->request_body->content->orderid);
        $mid = intval($this->request_body->content->mid);

        if(!$orderid || !$mid)
        {
            $this->send_datagrams($this->client_info['id'], array('status'=> false, 'msg'=> '提交信息有误'), $this->client_info['secret_key']);
        }

        // 获取订单信息
        $info = DB::select()->from("member_order")->where("memberid","=",$mid)->and_where("id","=",$orderid)->execute()->current();
        if (empty($info))
        {
            $this->send_datagrams($this->client_info['id'],  array('status'=> false, 'msg'=> '查找订单信息失败'), $this->client_info['secret_key'], false, "查找订单信息失败", "查找订单信息失败");
        }
        else
        {
            $payInfo = array();
            // 支付信息
            if($info['paytime'])
            {
                $payInfo['paytime'] = $info['paytime'] ? date("Y-m-d H:i",$info['paytime']) : '';
                $payInfo['payment_proof'] = $info['payment_proof'] ? Model_Api_Standard_System::reorganized_resource_url($info['payment_proof']) : '';
                $payInfo['paysource'] = $info['paysource'];
                if($info['online_transaction_no'])
                {
                    $online_transaction_no = json_decode($info['online_transaction_no'],true);
                    $payInfo['transaction_no'] = isset($online_transaction_no['transaction_no']) ? $online_transaction_no['transaction_no'] : '';
                }
            }
            $result = array('status'=> true,'msg'=> '获取成功','payInfo'=> $payInfo);
            $this->send_datagrams($this->client_info['id'], $result, $this->client_info['secret_key']);
        }

    }

}